package com.java2018.springmvc.author.service;

import com.java2018.springmvc.author.dao.AuthorMapper;
import com.java2018.springmvc.author.model.Author;
import com.java2018.springmvc.author.model.AuthorExample;
import com.java2018.springmvc.utils.uuid.UUIDUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AuthorServiceImpl  implements AuthorService{
    @Autowired
    AuthorMapper authorMapper;
    @Override
    public int add(Author author) {
        author.setId(UUIDUtil.getUUID());
        int count = authorMapper.insert(author);
        return count;
    }

    @Override
    public List<Author> getAll() {
        AuthorExample authorExample = new AuthorExample();
        return authorMapper.selectByExample(authorExample);

    }

    @Override
    public Author getOne(Author author) {
        return authorMapper.selectByPrimaryKey(author.getId());
    }
}
